<?
layout("/inc/layout.html",{title:sysTitle}){
?>
<script type="text/javascript" src="static/My97DatePicker/WdatePicker.js"></script>
<div id="page-wrapper">
	<!--BEGIN TITLE & BREADCRUMB PAGE-->
	<div id="title-breadcrumb-option-demo" class="page-title-breadcrumb">
		<div class="page-header pull-left">
			<div class="page-title">订单管理</div>
		</div>
		<ol class="breadcrumb page-breadcrumb pull-left">
			<li><i class="fa fa-home"></i>&nbsp;<a href="main.html">首页</a>&nbsp;&nbsp;<i
				class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
			<li>数字资源统一交易管理&nbsp;&nbsp;<i class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
			<li class="active">订单管理</li>
		</ol>

		<div class="clearfix"></div>
	</div>
	<!--END TITLE & BREADCRUMB PAGE-->
	<!--BEGIN CONTENT-->
	<div class="page-content">


		<div class="row mbl" >
			<div class="col-lg-12">
					<table style="width: 95%;margin-top: 20px;">
						<tr height="50">
							<td align="right" style="width: 100px;">订单号&nbsp;&nbsp;</td>
							<td><input type="text" class="form-control" style="width: 100%;" id="orderNumber" name="orderNumber" /></td> 
							<td align="right" style="width: 100px;">用户名&nbsp;&nbsp;</td>
							<td><input type="text" class="form-control" style="width: 100%;" id="memberUsername" name="memberUsername" /></td>
							<td align="right" style="width: 100px;">是否支付成功&nbsp;&nbsp;</td>
							<td>
								<select class="form-control" id="status">
									<option value="">请选择</option>
									<option value="0">成功</option>
									<option value="1">待支付</option>
								</select>
							</td>
							<td align="right" style="width: 100px;">支付方式&nbsp;&nbsp;</td>
							<td>
								<select class="form-control" id="payWay">
									<option value="">请选择</option>
									<option value="we_chat">we_chat</option>
									<option value="alipay">alipay</option>
									<option value="union_pay">union_pay</option>
									<option value="balance">balance</option>
								</select>
							</td>
						</tr>
						<tr height="50">
							<td align="right" style="width: 100px;">用户类型&nbsp;&nbsp;</td>
							<td>
								<select class="form-control" id="memberType">
									<option value="">请选择</option>
									<option value="0">个人</option>
									<option value="1">机构</option>
								</select>
							</td>
							<td align="right">开始时间&nbsp;&nbsp;</td>
							<td>
								<input type=vtext" class="form-control" style="width: 100%;float: right;" id="startTime" name="startTime" onclick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>
							</td>
							<td align="right">结束时间&nbsp;&nbsp;</td>
							<td>
								<input type="text" class="form-control" style="width: 100%; float: right;" id="endTime" name="endTime" onclick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>
							</td>
							<td align="right">&nbsp;&nbsp;</td>
						</tr>
					</table>
					<div style="margin-left: 40px;">
						<button type="button"  data-toggle="dropdown" class="btn btn-success dropdown-toggle" onclick="demo(1)">查询</button>
						<button type="button"  data-toggle="dropdown" class="btn btn-success dropdown-toggle" onclick="exportIndent()">导出订单</button>
						<button type="button"  data-toggle="dropdown" class="btn btn-success dropdown-toggle" onclick="exportIndentDetails()">导出订单详情</button>
					</div>					
			</div>
		</div>

		<table
			class="table table-hover table-striped table-bordered table-advanced tablesorter mbn">
			<thead>
				<tr>
					<th >序号</th>
					<th >用户名</th>
					<th >用户类型</th>
					<th >支付方式</th>
					<th >电话</th>
					<th >订单号</th>
					<th >资源支付金额</th>
					<th >资源优惠/折扣总金额</th>
					<th >状态</th> 
					<th >订单日期</th> 
					<th >可操作</th>
				</tr>
			</thead>
			<tbody id="findUser">
			</tbody>
		</table>
		<div id="dataNull" class="panel-body"
				style="height: 90px; line-height: 50px;" align="center">
		</div>
		<div id="page2" style="text-align: center; margin-top: 20px;"></div>
	</div>

	<!--END CONTENT-->
	<form action="exportIndentsubmit.do" method="post" name="exportIndentsubmit" target="_blank"></form>
</div>


<?} ?>
<script>
	var curr;
	var id;
	$(function() {
		
		demo(1);
	});
	function get() {
		demo1(curr);
	}
	function getlay() {
		return id;
	}
	function queryDetail(lid) {
		id = lid;
		layer.open({
			type : 2,
			area : [ '1100px', '630px' ],
		    scrollbar: false,
		    shadeClose: true,
			fix : false, //不固定
			title : '订单详情',
			//maxmin : true,  
			skin: 'layui-layer-rim', //加上边框
    	    btn: ['关闭'],
			content : ["pay-application-organization-rechargeable-detail.html",'no'],
		});
	}
	function demo(curr) {
		if ($.trim($("#startTime").val()).length > 1) {
			if ($.trim($("#endTime").val()).length < 1) {
				alert('请选择结束时间！');
				return null;
			}	
		}
		if ($.trim($("#endTime").val()).length > 1) {
			if ($.trim($("#startTime").val()).length < 1) {
				alert('请选择开始时间！');
				return null;
			}	
		}
		$.getJSON("queryrechargeable.do",
			{
				page : curr || 1,
				orderNumber:$("#orderNumber").val(),
        		memberUsername:$("#memberUsername").val(),
        		status:$("#status").val(),
        		payWay:$("#payWay").val(),
        		memberType:$("#memberType").val(),
        		startTime:$("#startTime").val(),
        		endTime:$("#endTime").val(),
			},
			function(res) {
			//alert(JSON.stringify(res));
				//此处仅仅是为了演示变化的内容
				var str = "";
				$("#findUser").html("");
				if(res[0].payOrderList.length>0){
					$("#dataNull").html("");
				}else{
					$("#dataNull").html("<span class='subtitle' style='font-size: 15px;'>数据为空!</span>");
				}
				for ( var i = 0; i < res[0].payOrderList.length; i++) {
					var start='';
					if(res[0].payOrderList[i].status == '0'){
						start='支付成功';
					}else{
						start='待支付';
					}
					var memberType='';
					if(res[0].payOrderList[i].memberType == '0'){
						memberType='个人';
					}else{
						memberType='机构';
					}
					str += "<tr><td>"
							+ (i + 1)
							+ "</td><td> <label id=>"
							+ res[0].payOrderList[i].memberUsername
							+ "</label></td><td><label >"
							+ memberType
							+ "</label></td><td><label >"
							+ res[0].payOrderList[i].payWay
							+ "</label></td><td><label >"
							+ res[0].payOrderList[i].mobilephone
							+ "</label></td><td><label >"
							+ res[0].payOrderList[i].orderNumber
							+ "</label></td><td><label >"
							+ res[0].payOrderList[i].payMoney.toFixed(2)
							+ "</label></td><td><label >"
							+ res[0].payOrderList[i].payPreferential.toFixed(2)
							+ "</label></td><td><label >"
							+ start
							+ "</label></td><td><label >"
							+ res[0].payOrderList[i].createTime
							+ "</label></td><td>"
							+ "<button type=\"button\" class=\"btn btn-default btn-xs\"  onclick=\"queryDetail('"
							+ res[0].payOrderList[i].id
							+ "')\">"
							+ "查询详情"
							+ "</button>" + "</td></tr>";
				}
				$("#findUser").append(str);

				laypage({
					cont : document.getElementById('page2'), //容器。值支持id名、原生dom对象，jquery对象,
					pages : res[0].count, //总页数
					skip : true, //是否开启跳页
					skin : 'molv', //加载内置皮肤，也可以直接赋值16进制颜色值，如:#c00
					curr: curr || 1,
					last: res[0].count,
					groups : 6,//连续显示分页数
					jump : function(obj, first) { //触发分页后的回调
						if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
							demo(obj.curr);
							 var curr = obj.curr;
			                 curr=obj.curr;
						}
					}
				});
			});
	};
	//导出订单
	function exportIndent(){
		/* if (confirm("是否确认导出！！")) {
			document.forms['exportIndentsubmit'].submit();
		} */
		if (confirm("是否确认导出！！")) {
			var _downiframe = $("iframe#_downiframe");
			if (_downiframe.length == 0) {
				_downiframe =$("<iframe id='_downiframe' name='_downiframe' style='display:none'></iframe>").appendTo($("body"));
			}
			_downiframe.attr("src", "exportIndentsubmit.do");
		}
	}
	//导出订单详情
	function exportIndentDetails(){
		if (confirm("是否确认导出！！")) {
			var _downiframe = $("iframe#_downiframe");
			if (_downiframe.length == 0) {
				_downiframe =$("<iframe id='_downiframe' name='_downiframe' style='display:none'></iframe>").appendTo($("body"));
			}
			_downiframe.attr("src", "exportIndentsubmitDetails.do");
		}
	}
	
</script>